/**
 * @param {string[]} words
 * @return {string[]}
 */
var stringMatching = function (words) {
  let res = []
  for (let i = 0; i < words.length; i++) {
    for (let j = 0; j < words.length; j++) {
      if(j==i) continue
      if (words[j].indexOf(words[i]) > -1) {
        res.push(words[i])
      }
    }
  }

  return res
}

stringMatching(["mass","as","hero","superhero"])